<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  var a = {
    modelData: [
      {
        m: 1,
        children: [
          {
            m:2,
            children:[
              {
                m:3,
                children:[
                  {
                    m:4
                  }
                ]
              }
            ]
          }
        ]
      },{
        m: 11,
        children: [
          {
            m:22,
            children:[
              {
                m:33,
                children:[
                  {
                    m:44
                  }
                ]
              }
            ]
          },
          {
            m:221,
            children:[
              {
                m:331,
                children:[
                  {
                    m:441
                  },{
                    m:443
                  }
                ]
              },{
                m:332,
                children:[
                  {
                    m:442
                  }
                ]
              }
            ]
          }
        ]
      },{
        m: 111,
        children: [
          {
            m:222,
            children:[
              {
                m:333,
                children:[
                  {
                    m:444
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  };
  var pos = [1,1,0,1];
  var _d;
  pos.forEach(function (d, i) {
    if (i == 0) {
      _d = a.modelData[d];
    } else if (i == pos.length - 1) {
      _d = _d.children[d];
      console.log('---d-->',_d);
      _d.m = 'bbbbb';
      var _item = {
        a:111,
        b:222,
        c:333
      }
      _d.m = _item;
  //              _d.text = self.edit.text.text;
  //              _d.color = self.edit.text.color;
  //              _d.size = self.edit.text.size;
  //              _d.css['font-size'] = self.edit.text.size + 'px';
  //              _d.css['color'] = self.edit.text.color;
    } else {
      _d = _d.children[d];
    }
  });
  console.log(JSON.stringify(a));
</script>
</body>
</html>
